//
//  StatusRetweetedCell.swift
//  weibo
//
//  Created by 吴婷婷 on 15/11/12.
//  Copyright © 2015年 wutingting. All rights reserved.
//

import UIKit
import SnapKit

class StatusRetweetedCell: StatusCell {
    //重写viewModel属性
    override var viewModel: StatusVewModel? {
        didSet{
            
            retweetedLabel.text = viewModel?.retweetedText
            
            pictureView.snp_updateConstraints { (make) -> Void in
                let offset = viewModel?.thumbnail?.count>0 ? StatusCellMargin: 0
                make.top.equalTo(retweetedLabel.snp_bottom).offset(offset)
            }
        }
    }
    
  
    //MARK: - 懒加载
    //背景按钮
    private lazy var backButton: UIButton = {
       
        let button = UIButton()
        button.backgroundColor = UIColor(white: 0.95, alpha: 1)
        return button
    }()
    //转发内容
    private lazy var retweetedLabel = UILabel(
        title: "转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博转发微博微博转发微博转发微博转发微博转发微",
        color: UIColor.darkGrayColor(),
        fontSize: 14,
        screenInsert: StatusCellMargin)
    
}
//MARK: - 设置界面
extension StatusRetweetedCell {
    override func setupUI() {
        super.setupUI()
        
        contentView.insertSubview(backButton, belowSubview:pictureView)
        contentView.insertSubview(retweetedLabel, belowSubview:pictureView)
        
        backButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(contentLabel.snp_bottom).offset(StatusCellMargin)
            make.left.equalTo(contentView.snp_left)
            make.right.equalTo(contentView.snp_right)
            make.bottom.equalTo(bottomView.snp_top)
        }
        
        retweetedLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(backButton.snp_top).offset(StatusCellMargin)
            make.left.equalTo(backButton.snp_left).offset(StatusCellMargin)
        }
        
        pictureView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedLabel.snp_bottom)
            make.left.equalTo(retweetedLabel.snp_left)
            make.width.equalTo(300)
            make.height.equalTo(90)
        }
    }
}
